build-data
Include build data in your program.
Features
- Saves build-time data:
- Git commit, branch, and dirtiness
- Source modification date & time
- Rustc version
- Rust channel (stable, nightly, or beta)
- Does all of its work in your
build.rs
. - Sets environment variables.
Use
env!
to use them in your program. - No macros
- No runtime dependencies
- Light build dependencies
forbid(unsafe_code)
- 100% test coverage
Alternatives
- Environment variables that cargo sets for crates:
CARGO_PKG_NAME
CARGO_PKG_VERSION
CARGO_BIN_NAME
- others
vergen
- Mature & very popular
- Good API, needs only
env!
to retrieve values - Excellent test coverage
- Heavy build dependencies
build-info
- Mature
- Confusing API
- Uses procedural macros
Example
// Cargo.toml
[]
[]
= "0"
Add a build.rs
file next to your Cargo.toml
.
Call build_data::set_*
functions to
set variables.
// build.rs
Use env!
to access the
variables in your program:
// src/bin/main.rs
Cargo Geiger Safety Report
Metric output format: x/y
x = unsafe code used by the build
y = total unsafe code found in the crate
Symbols:
🔒 = No `unsafe` usage found, declares #![forbid(unsafe_code)]
❓ = No `unsafe` usage found, missing #![forbid(unsafe_code)]
☢️ = `unsafe` usage found
Functions Expressions Impls Traits Methods Dependency
0/0 0/0 0/0 0/0 0/0 🔒 build-data 0.1.4
0/0 2/48 2/2 0/0 0/0 ☢️ ├── chrono 0.4.24
0/0 21/24 0/0 0/0 1/1 ☢️ │ ├── iana-time-zone 0.1.56
0/0 3/3 0/0 0/0 2/2 ☢️ │ │ └── core-foundation-sys 0.8.4
0/0 0/0 0/0 0/0 0/0 ❓ │ ├── num-integer 0.1.45
0/0 6/12 0/0 0/0 0/0 ☢️ │ │ └── num-traits 0.2.15
0/0 6/12 0/0 0/0 0/0 ☢️ │ ├── num-traits 0.2.15
0/0 0/7 0/0 0/0 0/0 ❓ │ ├── rustc-serialize 0.3.24
1/1 216/216 0/0 0/0 0/0 ☢️ │ └── time 0.1.43
1/24 10/449 0/2 0/0 5/50 ☢️ │ ├── libc 0.2.141
0/0 0/7 0/0 0/0 0/0 ❓ │ └── rustc-serialize 0.3.24
0/0 0/0 0/0 0/0 0/0 🔒 ├── safe-lock 0.1.3
0/0 0/0 0/0 0/0 0/0 🔒 └── safe-regex 0.2.5
0/0 0/0 0/0 0/0 0/0 🔒 └── safe-regex-macro 0.2.5
0/0 0/0 0/0 0/0 0/0 🔒 ├── safe-proc-macro2 1.0.36
0/0 0/0 0/0 0/0 0/0 🔒 │ └── unicode-xid 0.2.4
0/0 0/0 0/0 0/0 0/0 🔒 └── safe-regex-compiler 0.2.5
0/0 0/0 0/0 0/0 0/0 🔒 ├── safe-proc-macro2 1.0.36
0/0 0/0 0/0 0/0 0/0 🔒 └── safe-quote 1.0.15
0/0 0/0 0/0 0/0 0/0 🔒 └── safe-proc-macro2 1.0.36
2/25 258/759 2/4 0/0 8/53
Changelog
- v0.1.5 - Update a dependency. Thanks dignifiedquire!
- v0.1.4 - Update a dependency.
- v0.1.3 - Update docs.
- v0.1.2 - Rewrote based on feedback from r/rust.
- v0.1.1 - Update docs.
- v0.1.0 - Initial version
To Do
License: Apache-2.0